package com.example.vpn_demo.viewmodel

import android.util.Log
import androidx.lifecycle.ViewModel
import com.example.vpn_demo.model.HttpRequest
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

class NetworkViewModel : ViewModel() {
    private val _requests = MutableStateFlow<List<HttpRequest>>(emptyList())
    val requests = _requests.asStateFlow()

    fun addRequest(request: HttpRequest) {
        Log.d(TAG, "Adding new request: ${request.url}")
        _requests.value = _requests.value + request
        Log.d(TAG, "Current requests count: ${_requests.value.size}")
    }

    fun clearRequests() {
        Log.d(TAG, "Clearing all requests")
        _requests.value = emptyList()
    }

    companion object {
        private const val TAG = "NetworkViewModel"
    }
} 